perf: twisted Edwards lattice-based double-base MSM#1765
Open
yelhousni wants to merge 12 commits into
Open
Conversation
13 tasks
Contributor
Author
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b69a249. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
This PR is stacked on #1763 and contains the native twisted Edwards MSM follow-up only. It adds lattice-based double-base scalar multiplication variants for native twisted Edwards curves:
DoubleBaseScalarMulNonZeroas the optimized non-degenerate path.DoubleBaseScalarMulremains complete for the public API and handles zero scalars / identity edge cases before dispatching to the optimized non-zero path. The branch also includes the review fixes that remove redundant hint outputs, wire scalar decomposition verification into the twisted Edwards scalar multiplication path, and bind the non-GLV MSM hint to a single result with the sound relation[x1]P1 + [x2]P2 - [z]R = O.This PR intentionally does not include the emulated G2 GLV+FakeGLV work; that is split into #1764.
Type of change
How has this been tested?
Focused test run:
go test -short ./std/algebra/native/twistededwards ./internal/statsSpecifically covered:
How has this been benchmarked?
internal/stats/latest_stats.csvwas regenerated with new MSM(2) snippets.msm_G1_bn254_2msm_P256_2msm_secp256k1_2msm_babyjubjub_2msm_jubjub_2msm_bandersnatch_2Checklist:
golangci-lintdoes not output errors locallygnark-crypto/algebra/lattice)Note
High Risk
Changes in-circuit elliptic-curve MSM soundness (hints, LogUp tables, emulated scalar checks); mistakes could admit invalid witnesses in proofs.
Overview
Adds
DoubleBaseScalarMulNonZeroon native twisted Edwards curves: a fast path fors1·P1 + s2·P2when scalars and points are non-degenerate, whileDoubleBaseScalarMulstays the complete API.Non-GLV curves use a 3-MSM + LogUp path with joint multi-rational scalar decomposition (
r^(2/3)bits). Bandersnatch uses 6-MSM with GLV endomorphism params and extended multi-rational reconstruction (r^(1/3)bits). New hints (doubleBaseScalarMulHint,multiRationalReconstruct*) supply partial results; in-circuit checks enforce the MSM identity (e.g.[x1]P1 + [x2]P2 − [z]R = O).rationalReconstructdrops the integerkoutput (3 outputs instead of 4);scalarMulFakeGLVverifies decomposition via new emulated-mod-order helpers inscalar_decomp.go/emulatedparams.go.internal/statsgains MSM(2) snippets and updatedlatest_stats.csvfor constraint benchmarking.Reviewed by Cursor Bugbot for commit ad550d0. Bugbot is set up for automated code reviews on this repo. Configure here.